#include <iostream>
#include "ArmeDePres.h"
#include <cassert>


using namespace std;

ArmeDePres::ArmeDePres(std::string nom, int degats)
{
    m_nom=nom;
    m_degats=50;
}

ArmeDePres::~ArmeDePres(){}

void ArmeDePres::AttaquerDePres(int X, int Y, TabDeCells* TabDeCell, char orientation)
{
    Cellule* cible=0;
    switch(orientation)
    {
        case 'h' :
        cible = TabDeCell->GetAdresseCellule(X, Y-1);
        break;

        case 'b' :
        cible = TabDeCell->GetAdresseCellule(X, Y+1);
        break;

        case 'g' :
        cible = TabDeCell->GetAdresseCellule(X-1, Y);
        break;

        case 'd' :
        cible = TabDeCell->GetAdresseCellule(X+1, Y);
        break;
    }


    if(cible->GetAdresse() != 0 && cible->GetAdresse()->GetVie() != -1)
    {
        cible->GetAdresse()->RecevoirDegat(m_degats);

        if (cible->GetAdresse()->EstEnVie() == 0) TabDeCell->DetruireInstance(cible);
    }
}

std::string ArmeDePres::GetNomArme() const{return m_nom;}
int ArmeDePres::GetDegats() const {return m_degats;}
